{php include wl_template('common/header');}
<style>
.main_bd{padding-bottom:30px}
.plugins_wrp{padding:20px 30px}
.plugins_wrp .hd{margin-bottom:10px;padding-bottom:10px;border-bottom:1px solid #e7e7eb}
.plugins_wrp ul{margin-right:-24px;overflow:hidden;padding-left: 0px;}
.plugins_wrp .item_wrp{float:left;display:inline-block;*display:inline;*zoom:1;width:50%;position:relative;*width:49.9%}
.plugins_wrp .plugin_desc{padding-bottom:16px;color:#8d8d8d;margin: 14px 0;}
.table_wrp{padding:20px 30px}
.table_wrp .table_cell{height:40px;padding-left:20px;padding-right:20px}
.table_wrp .table_cell.plugin_name{width:450px}
.table_wrp .table_cell .privilege{color:#8d8d8d}
.table_wrp .table_cell .privilege .dot{font-style:normal;margin-right:5px}
.table_wrp .tbody .table_cell{padding-top:15px;padding-bottom:15px;vertical-align:top}
.table_wrp .plugin_logo{float:left;margin-right:10px}
.table_wrp .plugin_logo img{display:block;max-width:80px}
.table_wrp .plugin_info{overflow:hidden}
.table_wrp .plugin_info h4{font-weight:normal}
.table_wrp .plugin_info .desc{color:#8d8d8d}
.plugin_item{display:block;overflow:hidden;margin-right:24px;margin-bottom:24px;color:#222;height:92px;padding-left:94px;border:1px solid #e7e7eb}
.plugin_item:hover{text-decoration:none;background-color:#f4f5f9;border-color:#d9dadc}
.plugin_item .plugin_icon{position:absolute;width:92px;height:92px;background-color:#ccc;top:0;left:0}
.plugin_item .plugin_icon img {width: 92px;height: 92px;}
.plugin_item .plugin_status{position:relative;float:right;text-align:right;padding:35px 45px 35px 0}
.plugin_item .plugin_status .status_txt.warn{color:#e15f63}
.plugin_item .plugin_status .access{width:16px;height:16px;vertical-align:middle;display:inline-block;position:absolute;right:10px;top:40px}
.plugin_item .plugin_content{padding:10px 0 10px 20px;overflow:hidden}
.plugin_item .plugin_content .title{margin-bottom:4px;width:216px;font-size:14px;font-weight:400;font-style:normal;margin-top: 0px;}
.plugin_item .plugin_content .desc{color:#8d8d8d;font-size:12px;line-height:24px;width:238px;margin: 12px 0;}
</style>
<style>
table thead tr th, table tbody tr td {text-align: center; width: 10%;}
table thead tr th:last-child, table tbody tr td:last-child {text-align: right;}
</style>
<div class="panel panel-default">
	<div class="panel-body table-responsive" style="padding: 0px;">
		<div class="main_bd">
        <div class="plugins_wrp">
            <dl>
                <dd>
                    <ul id="js_plugins">
						<li class="item_wrp" style="width: 100%;">
							<div class="plugin_item">
								<div class="plugin_icon"><img src="https://res.wx.qq.com/mpres/zh_CN/htmledition/comm_htmledition/images/icon/service/scan.png"></div>
								<div class="plugin_status">
									<i class="access"></i>
									<span class="status_txt">	
										<input class="flag" type="checkbox" name="help"  value="{$setting['helpbuy']}" {if $setting['helpbuy'] == 1}checked{/if} />
									</span>
								</div>
								<div class="plugin_content">
									<h3 class="title">找人代付</h3>
									<p class="desc" style="    width: 100%;">
										启用代付功能后，代付发起人（买家）下单后，可将订单分享给小伙伴（朋友圈、微信群、微信好友），请他帮忙付款。
										注意：代送订单有效期15天，逾期后未完成，进入全额退款流程；若有超额支付，则超付部分进入退款流程；
									</p>
								</div>
							</div>
						</li>
					</ul>
                </dd>
            </dl>
        </div>
    </div>
	</div>
</div>
<div class="clearfix coupon-list-top">
	<div><a href="javascript:;" class="btn btn-success js-create">新建</a></div>
</div>
<div class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-hover">
			<thead>
			<tr>
				<th class="text-left" style="">发起人的求助   <i class="fa fa-question-circle"></i></th>
				<th class="text-center" style="width:160px;">操作</th>
			</tr>
			</thead>
			<tbody id="add">
			{loop $list $item}
			<tr data-toggle="popover" data-trigger="hover" data-placement="left" class="js-goods-img">
				<td class="line-feed text-left" id="name{$item['id']}">{$item['name']}</td>
				<td class="text-left">
					<a href="javascript:;" class="js-edit" order-id="{$item['id']}" order-name="{$item['name']}">编辑</a> - 
					<a href="javascript:;" class="js-delete" order-id="{$item['id']}">删除</a>
				</td>
			</tr>
			{/loop}
			</tbody>
		</table>
	</div>
</div>
{$pager}
<div class="modal in" id="order-remark-container" style="display: none;">	
<div class="modal-dialog">		
<div class="modal-content">			
<div class="modal-header">				
	<button type="button" class="close"><span id="close">×</span></button>				
	<h4 class="modal-title">添加</h4>			
</div>			
<div class="modal-body">				
	<textarea id="remark" name="admin_remark" class="form-control" rows="5" oninput="$(this).parent().next().find('.js-count').text(255 - $(this).val().length);;" onpropertychange="$(this).parent().next().find('.js-count').text(255 - $(this).val().length);;" maxlength="255" placeholder="最多填写 255 字"></textarea>			
</div>			
<div class="modal-footer" style="padding: 5px 15px;">				
	<span class="help-block pull-left">					
		您还可以输入：<storng><span style="color:red; font-size:18px;" name="count" class="js-count">251</span></storng> 个字符				
	</span>				
	<a class="btn btn-default js-cancel">取消</a>				
	<a class="btn btn-primary js-order-remark-post" order-id="">确定</a>			
</div>		
</div>	
</div>
</div>
<style>
.inner__content {background: #eee none repeat scroll 0 0;border-top: 1px solid #dcdcdc;box-sizing: border-box;color: #666;margin-top: 10px;margin-bottom:10px;min-width: 100%;padding: 10px 5px;width: auto;text-align:center;}
</style>
<script>
$(function(){
	require(['bootstrap.switch'],function($){
		$('.flag:checkbox').bootstrapSwitch({onText: '启用', offText: '禁用'});
		$('.bootstrap-switch-wrapper').click(function(e){
			e.stopPropagation();
			$.post("{php echo web_url('application/helpbuy/ajax')}",function(d){
				if(!d.errno){
					util.tips(d.message);
				}
			},"json");
		});
	});
	// 新建
		$('.js-create').click(function(e) {
			$('#order-remark-container').show();
			$('.panel').css("opacity","0.2");$('.nav').css("opacity","0.2");
		});
		$('.js-cancel,.close').click(function(e) {
			$('#order-remark-container').hide();
			$('.panel').css("opacity","1");$('.nav').css("opacity","1");
		});
		$('.js-order-remark-post').click(function() {
			var order_id = $(this).attr('order-id');
			var remark = $('#remark').val();
			$.post("{php echo web_url('application/helpbuy/create')}",{id:order_id,remark:remark},function(d){
				if(!d.errno){
					if(order_id){
						$('#name'+order_id).html(remark);
					}else{
						var data = '<tr data-toggle="popover" data-trigger="hover" data-placement="left" class="js-goods-img">'
									+'<td class="line-feed text-left">'+remark
									+'</td>'
									+'<td class="text-left">'
										+'<a href="javascript:;" class="js-edit" order-id="'+d.id+'">编辑</a> - '
										+'<a href="javascript:;" class="js-delete" order-id="'+d.id+'">删除</a>'
									+'</td>'
								+'</tr>';
						
						$('#add').append(data);
					}
					
				}
			},"json");
			$('#order-remark-container').hide();
			$('.panel').css("opacity","1");$('.nav').css("opacity","1");
		});
		$('.js-edit').click(function(e) {
			var order_id = $(this).attr('order-id');
			var order_name = $(this).attr('order-name');
			$('#remark').val(order_name);
			$('.js-order-remark-post').attr("order-id",order_id);
			$('#order-remark-container').show();
			$('.panel').css("opacity","0.2");
			$('.nav').css("opacity","0.2");
		});
		$('.js-delete').click(function(e) {
			e.stopPropagation();
			var order_id = $(this).attr('order-id');
			var _this = $(this);
			util.nailConfirm(this, function(state) {
				if(!state) return;
				_this.parent().parent().remove();
				$.post("{php echo web_url('application/helpbuy/delete');}", { id : order_id }, function(data){
						util.tips(data.message);
				}, 'json');
			}, {html: "确定删除！"});
			
		});
	$(".scrollLoading").scrollLoading();
	var $pop = null;
	$('.scrollLoading').hover(function(){
		var img = $(this).attr('src');
		var obj = this;
		var $pop = util.popover(obj, function($popover, obj){
			obj.$popover = $popover;
		}, '<div><img src="'+img+'" style="max-width:200px; max-height:200px;"></div>');
	}, function(){
		this.$popover.remove();
	});
});
</script>
{php include wl_template('common/footer');}
